using System;
using System.ComponentModel;
using System.Transactions;

using SIS.ENT;
using SIS.DAL;


namespace SIS.BLL
{

    /// <summary>
    /// The StudentFeeTableManager class is responsible for managing BO.StudentFeeTable objects in the system.
    /// </summary>
    [DataObjectAttribute()]
    public class StudentFeeTableManager
    {

        #region "Public Methods"

        /// <summary>
        /// Gets a list with all StudentFeeTable objects in the database.
        /// </summary>
        /// <returns>A list with all StudentFeeTable from the database when the database contains any, or null otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Select, true)]
        public static StudentFeeTableList GetList()
        {
            return StudentFeeTableDB.GetList();
        }

        /// <summary>
        /// Gets a single StudentFeeTable from the database without its data.
        /// </summary>
        /// <param name="studentFeeKey">The StudentFeeKey of the StudentFeeTable in the database.</param>
        /// <returns>A StudentFeeTable object when the StudentFeeKey exists in the database, or <see langword="null"/> otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public static StudentFeeTable GetItem(int studentFeeKey)
        {
            return GetItem(studentFeeKey, false);
        }

        /// <summary>
        /// Gets a single StudentFeeTable from the database.
        /// </summary>
        /// <param name="studentFeeKey">The StudentFeeKey of the StudentFeeTable in the database.</param>
        /// <param name="getStudentFeeTableRecords">Determines whether to load all associated StudentFeeTable records as well.</param>
        /// <returns>
        /// A StudentFeeTable object when the StudentFeeKey exists in the database, or <see langword="null"/> otherwise.
        /// </returns>
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public static StudentFeeTable GetItem(int studentFeeKey, bool getStudentFeeTableRecords)
        {
            StudentFeeTable myStudentFeeTable = StudentFeeTableDB.GetItem(studentFeeKey);
            return myStudentFeeTable;
        }

        /// <summary>
        /// Saves a StudentFeeTable in the database.
        /// </summary>
        /// <param name="myStudentFeeTable">The StudentFeeTable instance to save.</param>
        /// <returns>The new StudentFeeKey if the StudentFeeTable is new in the database or the existing StudentFeeKey when an item was updated.</returns>
        [DataObjectMethod(DataObjectMethodType.Update, true)]
        public static int Save(StudentFeeTable myStudentFeeTable)
        {
            using (TransactionScope myTransactionScope = new TransactionScope())
            {
                int studentFeeTableStudentFeeKey = StudentFeeTableDB.Save(myStudentFeeTable);

                //  Assign the StudentFeeTable its new (or existing StudentFeeKey).
                myStudentFeeTable.StudentFeeKey = studentFeeTableStudentFeeKey;

                myTransactionScope.Complete();

                return studentFeeTableStudentFeeKey;
            }
        }

        /// <summary>
        /// Deletes a StudentFeeTable from the database.
        /// </summary>
        /// <param name="myStudentFeeTable">The StudentFeeTable instance to delete.</param>
        /// <returns>Returns true when the object was deleted successfully, or false otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Delete, true)]
        public static bool Delete(StudentFeeTable myStudentFeeTable)
        {
            return StudentFeeTableDB.Delete(myStudentFeeTable.StudentFeeKey);
        }

        #endregion

    }

}
